package fr.ants.view.component;

import java.io.File;

import javax.swing.filechooser.FileFilter;

import fr.ants.utils.Formatter;

/**
 * {@link FileFilter} that allows CSV extension.
 * 
 */
public class PngFileFilter extends FileFilter {

	/** allowed extension. */
	final static String PNG = "png";

	/**
	 * Constructor.
	 */
	public PngFileFilter() {
		// empty constructor
	}

	/*
	 * Checks if the file is allowed.
	 */
	@Override
	public boolean accept(final File file) {
		if (file.isDirectory()) {
			return true;
		}

		String extension = Formatter.getExtension(file);
		// check if the extension is png
		if (extension != null) {
			if (extension.equals(PNG)) {
				return true;
			}
		}

		return false;
	}

	@Override
	public String getDescription() {
		return "Png";
	}
}
